package cn.zynworld.hnister.chats.service;

import cn.zynworld.hnister.chats.dto.ChatMessageDTO;
import cn.zynworld.hnister.chats.enums.MqttQosEnum;
import cn.zynworld.hnister.chats.manager.MqttManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

/**
 * @auther Buynow Zhao
 * @create 2018/5/6
 */
@Service
public class ChatService {
	@Autowired
	private MqttManager mqttManager;

	@Value("${mqtt.topic.chat}")
	private String CHAT_TOPIC;

	public void publishChatMessage(ChatMessageDTO chatMessageDTO) {
		mqttManager.publish(CHAT_TOPIC,chatMessageDTO, MqttQosEnum.MOST_ONCE.getCode(),false);
	}

}
